<template>
  <div class="container">
    <div class="deep-cosmos"></div>
    <div ref="container" class="three-container"></div>
  </div>
</template>

<script setup>
// 原有脚本部分保持不变
import { ref, onMounted, onUnmounted } from 'vue'
import lineMap from '@/components/Map/map.js'

const container = ref(null)
let mapInstance = null

onMounted(() => {
  if (container.value) {
    mapInstance = new lineMap(container.value)
    mapInstance.init()
    window.addEventListener('resize', () => mapInstance.resize())
  }
})

onUnmounted(() => {
  if (mapInstance) {
    mapInstance.destroy()
    mapInstance = null
  }
})
</script>

<style scoped>
.container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.three-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.deep-cosmos {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: linear-gradient(
    135deg,
    #04040a 0%,
    #0a0a12 25%,
    #101018 50%,
    #181822 75%,
    #1c1c28 100%
  );
  background-size: 400% 400%;
  animation: deep-space-flow 30s linear infinite;
  opacity: 0.95;
}

@keyframes deep-space-flow {
  0% {
    background-position: 0% 0%;
    opacity: 0.9;
  }
  50% {
    background-position: 100% 100%;
    opacity: 1;
  }
  100% {
    background-position: 0% 0%;
    opacity: 0.9;
  }
}

/* 添加星空微光效果 */
.deep-cosmos::after {
  content: "";
  position: absolute;
  width: 200%;
  height: 200%;
  background: 
    radial-gradient(circle at 50% 50%, 
      rgba(255,255,255,0) 60%,
      rgba(255,255,255,0.02) 70%,
      rgba(255,255,255,0) 80%
    ),
    radial-gradient(circle at 30% 20%, 
      rgba(255,255,255,0) 85%,
      rgba(255,255,255,0.03) 90%,
      rgba(255,255,255,0) 95%
    );
  animation: star-twinkle 8s ease-in-out infinite;
}

@keyframes star-twinkle {
  0%, 100% {
    transform: translate(0, 0);
    opacity: 0.8;
  }
  50% {
    transform: translate(50px, 50px);
    opacity: 1;
  }
}
</style>